package com.networkmmc.demo.ctrlr;

import com.networkmmc.demo.services.ProcessDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @Autowired
    private ProcessDataService processDataService;

    @RequestMapping("/run")
    @ResponseBody
    public String run(@RequestParam("filePath") String filePath, @RequestParam(name = "sheetIndex", required = false, defaultValue = "0") int sheetIndex, @RequestParam(name = "sheetLength", required = false, defaultValue = "1") int sheetLength, @RequestParam(name = "multiFile", required = false, defaultValue = "false") boolean multiFile, @RequestParam(name = "maxFileNum", required = false, defaultValue = "1") int maxFileNum){
        new Thread(new Runnable() {
            @Override
            public void run() {
                processDataService.proc(filePath, sheetIndex, sheetLength, multiFile, maxFileNum);
            }
        }).start();
        return "请求成功，请在控制台查看处理结果";
    }
}
